package com.obtk.byproperty.controller;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.obtk.byproperty.pojo.Activity;
import com.obtk.byproperty.pojo.WXQueryParams;
import com.obtk.byproperty.service.ActivityService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/activity")
public class ActivityController {

    @Autowired
    private ActivityService activityService;

    @RequestMapping("/getActivity")
    public List<Activity> getActivity(){
       List<Activity> activityList= activityService.selectAll();
        return activityList;
    }
    @RequestMapping("/getActivity/page")
    public PageInfo<Activity> getActivityPage(WXQueryParams wxQueryParams){
        //开启分页功能
        PageHelper.startPage(wxQueryParams.getPagenum(),wxQueryParams.getPagesize());
        List<Activity> activities=activityService.slectBookPage(wxQueryParams.getCommunityName());
        PageInfo<Activity> activityPageInfo = new PageInfo<>(activities);
        return activityPageInfo;

    }
    @RequestMapping("/getActivityAllName")
    public List<String> getActivityAllName(){
        List<String> activities= activityService.getActivityAllName();
        return activities;
    }
    //模糊查询
    @RequestMapping("/getActivityTitle")
    public List<Activity> getActivityTitle(String title,String communityName){
       List<Activity> activitiyTitle= activityService.search(title,communityName);
       return activitiyTitle;
    }
    @RequestMapping("/selectActivity")
    public List<Activity> selectActivity(String title,String communityName){
      List<Activity> activitie= activityService.selectActivity(title,communityName);
        return activitie;
    }

}
